package cn.getech.data.metadata.controller;

import cn.getech.data.metadata.model.res.CollectionTableOperateType2Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.getech.data.metadata.entity.CollectionTableOperateEntity;
import cn.getech.data.metadata.service.CollectionTableOperateService;
import cn.getech.data.metadata.model.req.collectiontableoperate.*;
import cn.getech.data.metadata.model.res.CollectionTableOperateListRes;
import cn.getech.data.intelligence.common.utils.BaseRes;
import cn.getech.data.intelligence.common.utils.DataRes;
import cn.getech.data.intelligence.common.utils.PageRes;
import cn.getech.data.intelligence.common.utils.PageUtils2;
import cn.getech.data.intelligence.common.validator.ValidatorUtils;
import cn.getech.data.intelligence.common.validator.group.AddGroup;
import cn.getech.data.intelligence.common.validator.group.UpdateGroup;



/**
 * 采集表操作审计
 *
 * @author qiuxinglei
 * @email qiuxinglei@gmail.com
 * @date 2020-09-29 17:40:13
 */
@Api(value="采集表操作审计",tags={"采集表操作审计"})
@RestController
@RequestMapping("md/collectiontableoperate")
public class CollectionTableOperateController {
    @Autowired
    private CollectionTableOperateService collectionTableOperateService;

    @ApiOperation("列表")
    @PostMapping("/list")
    public PageRes<PageUtils2<CollectionTableOperateListRes>> list(@RequestBody  CollectionTableOperateListReq req){
        ValidatorUtils.validateEntity(req, AddGroup.class);
        PageUtils2<CollectionTableOperateListRes> page = collectionTableOperateService.list(req);

        return BaseRes.okWithPage(page);
    }


    @ApiOperation("信息")
    @GetMapping("/info/{operateId}")
    public DataRes<CollectionTableOperateEntity> info(@PathVariable("operateId") Long operateId){
        CollectionTableOperateEntity collectionTableOperate = collectionTableOperateService.getById(operateId);

        return BaseRes.okWithData(collectionTableOperate);
    }

    @ApiOperation("表属性信息")
    @GetMapping("/type2Info/{operateId}")
    public DataRes<CollectionTableOperateType2Res> type2Info(@PathVariable("operateId") Long operateId){
        CollectionTableOperateType2Res res = collectionTableOperateService.info(operateId);

        return BaseRes.okWithData(res);
    }
}
